
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title><%= title %></title>
    <link rel="stylesheet" href="../stylesheets/bootstrap.min.css" media="screen">
    <style type="text/css">
    .m15{ margin: 15px;}
     .tc{ text-align: center;font-size: 18px;font-weight: 600;}
    </style>
</head>
<body screen_capture_injected="true">
    <div class="container">
        <form class="col-sm-offset-4 col-sm-4 form-horizontal" role="form" method="post" onsubmit="return false">
            <fieldset>
                <legend></legend>
                <div class="panel panel-default">
                <div class="panel-heading">
                    <p class="tc">注册信息</p>
                </div>
                <div class="panel-body m15">
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">
                        <span class="glyphicon glyphicon-user"></span>
                        </span>
                        <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名" required>
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">
                        <span class="glyphicon glyphicon-lock"></span>
                        </span>
                        <input type="text" class="form-control" id="password" name="password" placeholder="请输入密码" required>
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">
                        <span class="glyphicon glyphicon-lock"></span>
                        </span>
                        <input type="text" class="form-control" id="password1" name="password1" placeholder="请再次输入密码" required>
                    </div>
                </div>
                <div class="form-group">
                        <button type="button" class="btn btn-primary btn-block" id="register1">注册</button>
                </div>
                <div class="form-group">
                        <button type="button" class="btn btn-info col-sm-2 col-sm-offset-10" id="login1">登录</button>
                </div>
                </div>
                </div>
            </fieldset>
        </form>
    </div>

<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>

<script type="text/javascript" src="../javascripts/bootstrap.min.js"></script>
<script type="text/javascript" src="../javascripts/layer/layer.js"></script>
<script type="text/javascript">
    $(function(){
        $("#login1").click(function(){
            location.href = '/index';
        });
        $("#register1").click(function(){
            var username = $("#username").val();
            var password = $("#password").val();
            var password1 = $("#password1").val();
            alert(username);
            if(password !== password1){
                $("#password").css("border","1px solid red");
                $("#password1").css("border","1px solid red");
            }else if(password === password1){
            var data = {"uname":username,"upwd":password};
            $.ajax({
                url: 'reg',
                type: 'post',
                data: data,
                success: function(data){
                    var d=eval(data);
                    if(d.code==10){
                       alert(d.msg);
                      setTimeout(function(){
                       location.href = '/index';
                      },100)
                    }
                     if(d.code==11){
                       layer.alert('账号已被注册，请重新输入', {icon: 6});
                    }
                },
                error: function(data,err){
                        location.href = 'login';
                }
            });
        }
        });
    });
</script>
</body>
</head>
</html>